/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

.branch-indicator {
  stroke: var(--foreground);
  position: absolute;
  bottom: -20px;
  left: -30px;
  margin-bottom: -5px;
  z-index: 2;
}
.commit-group {
  margin-bottom: 30px;
  margin-bottom: 20px;
  margin-left: 20px;
  margin-top: 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: calc(var(--halfpad) / 2);
}
.commit-tree-root {
  margin-top: calc(2px + var(--halfpad));
}
.commit-tree-stack-actions {
  display: flex;
  flex-direction: row;
  gap: var(--pad);
  align-items: center;
  margin-top: var(--halfpad);
  margin-bottom: calc(2 * var(--pad));
  margin-left: var(--halfpad);
}

.commit-group.with-vertical-line:before {
  /* branch vertical line - used by split range selector */
  content: ' ';
  border-left: 2px solid var(--foreground);
  position: absolute;
  bottom: 5px;
  top: 20px;
  left: -10px;
  z-index: 1;
}
.commit {
  position: relative;
}

/* used by the split branch selection */
.commit-avatar {
  position: absolute;
  border: 1px solid var(--foreground);
  margin-bottom: 0px;
  z-index: 3;
  background-color: var(--foreground, hsla(0, 0%, 0%, 0.1));
  display: inline-block;
  vertical-align: top;
  overflow: hidden;
  left: -22px;
  top: auto;
  bottom: auto;
  border-radius: 50%;
  height: 16px;
  width: 16px;
  box-sizing: border-box;
  transition:
    transform 0.2s,
    box-shadow 0.3s;
}

/* Avatar may render below the top of the border,
 * cover up the border that peeks out the top with background color,
 * but only on the top commit of a stack
 */
.commit.topmost .commit-details:before {
  left: -15px;
  top: 0;
  content: '';
  width: 2px;
  height: calc(50%);
  background-color: var(--background);
  position: absolute;
}
.commit.topmost.head-commit .commit-details:before {
  background-color: var(--button-primary-hover-background);
}

.commit.highlighted .commit-avatar {
  box-shadow: 0px 0px 4px 2px var(--focus-border);
  transform: scale(1.2);
}

.head-commit .commit-avatar {
  border-color: var(--button-primary-hover-background);
}

.commit.obsolete .commit-title {
  opacity: 0.5;
}

.commit.irrelevant .commit-title {
  opacity: 0.5;
}

.commit-rows {
  display: flex;
  flex-direction: row;
  gap: calc(var(--halfpad) / 2) var(--halfpad);
  padding: calc(var(--halfpad) / 2);
  padding-left: 0;
  margin-left: var(--halfpad);
  position: relative;
  align-items: center;
  z-index: 1;
}

.commit-row-selected {
  background-color: var(--selected-commit-background);
}

.commit-tree-root {
  min-width: 450px;
}

.commit-tree-narrow .commit-rows {
  flex-direction: column;
  align-items: initial;
}

.commit-tree-narrow .commit-group {
  gap: 0;
}

.commit-details {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--halfpad) var(--pad);
  position: relative;
  box-sizing: border-box;
  user-select: none;
  /* Increase Draggable Commit size to overlap with avatar, without changing where the commit renders */
  margin-left: -30px;
  padding-left: 30px;
  /* Increase drag target for commit on the right so you can drag nearly anywhere on the row to preview the rebase */
  margin-right: -400px;
  padding-right: 400px;
  /* Put drag target behind buttons, so expanded ranges don't interfere with clicking buttons */
  z-index: -1;
}

.commit-title {
  min-width: 180px;
}

.commit-details:focus-visible {
  outline: var(--focus-border) 1px auto;
  outline-offset: var(--halfpad);
}

.commit-wide-drag-target {
  position: absolute;
  left: 0;
  top: 0;
  width: 500px; /* Arbitrary minimum size we want to be able to drag through, so we can't "miss" small commits */
  height: 100%;
  z-index: -100;
}

.commit-details > .tooltip-creator {
  display: flex;
  align-items: center;
}

.commit-second-row {
  display: flex;
  gap: var(--pad);
  align-items: center;
  flex-shrink: 0;
}

.commit-date {
  font-size: 90%;
  opacity: 0.8;
  margin: 0 2px;
}
.commit-title .commit-date {
  margin-left: var(--pad);
}

.commit .unsaved-message-indicator {
  color: var(--button-primary-background);
  display: flex;
}

.commit vscode-tag::part(control) {
  text-transform: unset;
}

.commit-preview-rebase-root,
.commit-preview-rebase-descendant {
  color: var(--scm-added-foreground);
}
.commit-preview-rebase-old {
  opacity: 0.5;
}

.commit-preview-hidden-root > .commit-title,
.commit-preview-hidden-descendant > .commit-title {
  opacity: 0.5;
  text-decoration: line-through;
}

.commit-inline-operation-progress {
  display: flex;
  flex-direction: row;
  align-items: center;
  font-size: 80%;
  gap: 10px;
  opacity: 0.9;
  margin-right: var(--halfpad);
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes delayFadeIn {
    0% {
      opacity: 0;
    }
    90% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }

  .commit-inline-operation-progress {
    animation: delayFadeIn 1s ease-in-out;
  }
}

.goto-button,
.open-commit-info-button {
  opacity: 0;
  transition: opacity 0.1s;
}

.commit:hover .goto-button,
.commit:hover .open-commit-info-button {
  opacity: 1;
}

.goto-button:focus-within,
.open-commit-info-button:focus-within {
  opacity: 1;
}

.stable-commit-metadata {
  display: flex;
}

.stable-commit-metadata vscode-tag::part(control) {
  background-color: var(--list-hover-background);
  color: var(--list-hover-foreground);
  text-overflow: ellipsis;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
}

.tooltip span.commit-title {
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 90%;
  background-color: var(--hover-darken);
}

.fetch-additional-commits-row {
  display: flex;
  align-items: center;
  margin: var(--halfpad);
  position: relative;
  min-height: var(--vscode-icon-button-height);
}
